<template>
	<view class="body_box">
		请联系管理员：电话13112341234
		<!-- <view class="header-box">
			<text>此注册为回收商总账号，仅限公司负责人注册，员工账号由负责人注册后添加或邀请，请如实填写信息。</text>
		</view>
		
		<view class="form-box">
			<u--form>
				<u-form-item 
					label="公司名称"
					label-width="180rpx"
					label-align="right"
					border-bottom
				>
					<u-input placeholder="请填写公司名称" border="none"></u-input>
				</u-form-item>
				<u-form-item
					label="负责人"
					label-width="180rpx"
					label-align="right"
					border-bottom
				>
					<u-input placeholder="请填写联系人姓名" border="none"></u-input>
				</u-form-item>
				<u-form-item
					label="联系电话"
					label-width="180rpx"
					label-align="right"
					border-bottom
				>
					<u-input placeholder="请填写联系电话" border="none"></u-input>
				</u-form-item>
				<u-form-item
					label="所在区域"
					label-width="180rpx"
					label-align="right"
					border-bottom
					@click="addressOpen = true"
				>
				<u-input placeholder="省、市、区/街道" disabled disabled-color="#fff" border="none"></u-input>
				<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
				<u-form-item
					label="详细地址"
					label-width="180rpx"
					label-align="right"
					border-bottom
				>
				<u-input v-model="form.detail" placeholder="请填写详情地址" border="none"></u-input>
				<view slot="right" @click="showAddressDetail">
					<u--image :src="dwSrc" width="20" height="20"></u--image>
				</view>
				</u-form-item>
				<u-form-item
					label="营业执照"
					label-width="180rpx"
					label-align="right"
					border-bottom
				>
					<u-upload
						:fileList="fileList1"
						@afterRead="afterRead"
						@delete="deletePic"
						name="1"
						multiple
						:maxCount="1"
					></u-upload>
				</u-form-item>
			</u--form>
		</view>
		
		<view style="margin-top: 30rpx;">
			<u-button type="success" size="large">提交</u-button>
		</view>
		
		
		<address-picker
			:show="addressOpen" 
			:address-data="addrData"
			:type="type"
			@confirm="confirmAddress"
			:indexs="indexs"
			closeOnClickOverlay
		></address-picker> -->
	</view>
</template>

<script>
import picker from '../../uni_modules/uview-ui/libs/config/props/picker'
	export default {
		data() {
			return {
				fileList1: [],
				dwSrc: require("@/static/img/dw.png"),
				address: '',
				addressOpen: false,
				addrData: ['重庆市', '重庆市', '渝中区'],
				type: 3, //1-省，2-省市，3-省市区
				indexs: [0,0,0],
				form: {
					detail: null
				}
			}
		},
		methods: {
			confirmAddress(val) {
				console.log(val)
				this.address = val.value.join('-')
				console.log(this.address)
				this.addressOpen = false
			},
			showAddressDetail() {
				uni.chooseLocation({
					success: (res) => {
						this.form.detail = res.name
					}
				});
			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: 'http://192.168.2.21:7001/upload', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							setTimeout(() => {
								resolve(res.data.data)
							}, 1000)
						}
					});
				})
			},
		}
	}
</script>

<style lang="scss">
	.header-box{
		border-radius: 30rpx;
		background-color: #fff;
		font-size: 26rpx;
		margin-top: 30rpx;
		padding: 40rpx 30rpx;
		color: $u-primary;
	} 
	.form-box {
		padding: 20rpx;
		margin-top: 50rpx;
		background-color: #fff;
		border-radius: 30rpx;
	}
</style>
